<template>
  <div>
    <div class="pvTop1">
      <router-link :to="{path:'/main/sitedetail'}">
        <div class="pvTop1_1">
          <van-icon name="arrow-left" />
        </div>
      </router-link>
      <div class="pvTop1_3">{{$t('Battery')}}</div>
    </div>
    <div class="pvBox">
      <div class="pvBox1" v-for="(bat,i) in resData" :key="i" @click="batteryDetail(bat.inverterSn,bat.wsn)">
        <div class="pvBox1_1">{{bat.inverterSn}}</div>
        <div class="loadBox1_2">{{$t('BatteryCapacity')}} : {{bat.batteryCapacity | numFilter(1)}}%</div>
        <div class="left"><van-icon name="arrow" /></div>
      </div>
    </div>
    <van-empty :description="$t('NoData')" v-if="resData.length==0" />
  </div>
</template>

<script>
export default {
  data(){
    return {
      resData:[],
      fifteenRefresh:null
    }
  },
  methods: {
    batteryDetail(inverterSn,wsn){
      localStorage.setItem("sn",inverterSn);
      localStorage.setItem('wifiSN',wsn)
      this.$router.push({path:'/batterydetail'});
    },
    async getBatteryList(){
      this.comm.loadingShow();
      let res = await this.API.getBatteryList(localStorage.getItem("domain"),{
        'tokenId':localStorage.getItem("tokenId"),
        'siteId':localStorage.getItem('siteId')
      })
      if(res.success){
        this.resData = res.result;
      }
    }
  },
  mounted() {
    this.getBatteryList();
    this.fifteenRefresh=setInterval(()=>{
      this.getBatteryList();
    },900000);
  },
  destroyed(){
    clearInterval(this.fifteenRefresh);
    this.fifteenRefresh=null;
  }
}
</script>

<style scoped lang="less">
.pvTop1{
  background: url("../assets/batterytop.png") no-repeat center  / 100% 100%;
  width: 100%;
  height: 150px;
  box-sizing: border-box;
}
.pvTop1_1{
  font-size: 30px;
  color: #FFFFFF;
  float: left;
  padding: 40px 16px 0 20px;
}
.pvTop1_3{
  font-size: 25px;
  font-weight: bolder;
  color: #FFFFFF;
  float: left;
  padding: 39px 0 0 10px;
}
.pvBox{
  position: absolute;
  top:95px;
  width: 100%;
  margin: 0 auto;
  padding:0 25px 10px 25px;
  box-sizing: border-box;
}
.pvBox1{
  height: 75px; 
  width: 100%; 
  margin-bottom: 10px; 
  background:#FFFFFF; 
  box-shadow: 1px 0px 4px #888888; 
  border-radius: 5px;
  position: relative;
}
.left{
  position: absolute;
  top:30px;
  right: 10px;
  font-size: 20px;
  color: #989898;
}
.pvBox1_1{
  width: 100%; 
  padding:15px 0 10px 15px; 
  color: #333544; 
  font-size: 16px; 
  white-space: nowrap;
  text-align: left;
  box-sizing: border-box;
}
.loadBox1_2{
  width: 100%; 
  padding:0 0 10px 15px; 
  color: #333544; 
  font-size: 16px; 
  white-space: nowrap;
  text-align: left;
  box-sizing: border-box;
}
</style>
